<?php

class Issue_model extends CI_Model {

    public $year = '';
    public $sublevel = '';
    public $category = '';
    public $title = '';
    public $subtitle = '';
    public $format = '';
    public $fs = '';

    function __construct() {
        parent::__construct();
    }

    public function by_id($id) {
        $this->db->get($table, 1, $id);
    }

    public function save() {
        $post = $this->input->post();
        
        var_dump($post);
        /*
        if($this->unique_field('title', $post['title'])
        ) {
            echo 'Ya exíste este título';
        } else {
            $this->db->insert('issues', $post);
        }
         */
    }

    public function unique_field($field, $value) {
        $query = $this->db->query('SELECT * FROM issues WHERE ' . $field . '="' . $value . '"');

        if (count($query->result()) > 0) {
            return 'FALSE';
        }
    }

}